﻿/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __CD31DB39_DCBD_47dc_A1C7_56382B92B992__
#define __CD31DB39_DCBD_47dc_A1C7_56382B92B992__

#include "../tools/head.h"

/////////////////////////////////////////////////////////////////////////////////////////
// 

namespace xos
{
    // 
    // mutex_impl
    // 
    class mutex_impl : public xos_stl::mem_item< release_impl< mutex_impl >, thread_lock >,
        public i_lock
    {
    public:
        typedef release_impl< mutex_impl > T;

    public:
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //

        static int get_addr( POOL *** pppPool, LIST *** pppList );

    public:
        mutex_impl();
        ~mutex_impl();

    protected:
        mutex m_lock;

    public:
        int init();
        int term();

    public:
        // 
        // un lock
        // 
        int un_lock();

        // 
        // lock
        // 
        int lock();
    };
} // xos

#endif // __CD31DB39_DCBD_47dc_A1C7_56382B92B992__
